﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HZY.Admin.Controllers.Sys
{
    using HZY.Toolkit;
    using HZY.Models.Sys;
    using HZY.DTO;
    using HZY.DTO.Sys;
    using HZY.Services.Sys;
    using HZY.Admin.Core;

    /// <summary>
    /// 修改密码
    /// </summary>
    public class ChangePasswordController : ApiBaseController
    {
        protected readonly AccountService service;

        public ChangePasswordController(
            AccountService _service
            ) : base(Guid.Parse("f35d64ae-ecb7-4d06-acfb-d91595966d9e"))
        {
            this.service = _service;
        }

        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        [HttpPost("Save"), HZYAuthorization]
        public async Task<ApiResult> UpdatePassword([FromBody]UpdatePasswordDto Model)
            => this.ResultOk(await this.service.ChangePwd(Model.OldPwd, Model.NewPwd));


    }
}